#include <algorithm>
#include <cstdio>
#include <typeinfo>

typedef unsigned long long ull;
const int N = 30005;
int n, l, s;
ull hash[201][N], tmp[N], radix[201];
char str[N][201];

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#endif
#ifndef LOCAL
  freopen("P4503[CTSC]Penguin.in", "r", stdin);
  freopen("P4503[CTSC]Penguin.out", "w", stdout);
#endif
#endif

  scanf("%d%d%d", &n, &l, &s);
  for (int i = 1; i <= n; ++i) {
    scanf("%s", str[i] + 1);
  }
  int ans = 0;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= l; ++j) {
    hash[j][i] = hash[j - 1][i] * 133 + str[i][j];
    }
  radix[0] = 1;
  for (int i = 1; i <= l; ++i) {
    radix[i] = radix[i - 1] * 133;
  }
  for (int i = 1; i <= l; ++i) {
    for (int j = 1; j <= n; ++j) {
      tmp[j] = hash[i - 1][j] * radix[l - i] + hash[l][j] - hash[i][j] * radix[l - i];
    }
    std::sort(tmp + 1, tmp + n + 1);
    int sum = 1;
    for (int j = 2; j <= n; ++j) {
      if (tmp[j] == tmp[j - 1])
        ans += sum, ++sum;
      else
        sum = 1;
    }
  }
  printf("%d", ans);
  return 0;
}